package com.wanxi.service;

import com.wanxi.dao.BrandDao;
import com.wanxi.model.BrandModel;

import java.util.List;

/**
 * @author Li
 * @Date 2023/4/26 15:36
 */
public class BrandService {
//    public int add(String brandName, String enterpriseName, String sort, String introduce, String status, String operate) {
//    return 0;
//    }

    /**
     * 增加数据
     * @param model
     * @return
     */
    public int add(BrandModel model) {
        if (model.getSort()<0){
            model.setSort(0);
        }
        if (model.getSort()>1000){
            model.setSort(1000);
        }
//调用dao数据层
        BrandDao brandDao = new BrandDao();
        int count = brandDao.add(model);
        return count;
    }

    /**
     * 查询全部数据
     * @return
     */
    public List<BrandModel> findAll() {
//      没有进行逻辑处理 ，直接调用dao层获取数据
        BrandDao brandDao = new BrandDao();
        return brandDao.findAll();
    }

    /**
     * 通过id删除数据
     * @param model
     * @return
     */
    public int deleteById(BrandModel model) {
        BrandDao brandDao = new BrandDao();
        return brandDao.deleteById(model);
    }

    public BrandModel findById(BrandModel brandModel) {
        BrandDao brandDao = new BrandDao();
        return brandDao.findById(brandModel);
    }

    public int update(BrandModel model) {
        BrandDao brandDao = new BrandDao();
        return brandDao.update(model);
    }
}
